package top.arryweb.application.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import top.arryweb.application.common.exception.BusinessRuntimeException;

/**
 * @author xiong04
 * @since 2021-05-02
 */
@AllArgsConstructor
@Getter
public enum TradeType {
	PAYMENT(1, "支付", "payment"),
	REFUND(2, "退款", "refund");

	private final Integer rank;

	private final String comments;

	private final String name;

	public static TradeType setRank(int rank) {
		return Arrays.stream(TradeType.values()).filter(tradeType -> tradeType.getRank() == rank).findFirst()
				.orElseThrow(() -> new BusinessRuntimeException("无此交易类型"));

	}
}
